﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Csla;
using lite;
using Csla.Validation;
using Csla.Data;
using System.Data.SqlClient;
using ZX.DAL;
using Csla.Core;
using OpenExpressApp.ORM;
using OpenExpressApp.MetaAttribute;
using OpenExpressApp.DB.Utils;
using OpenExpressApp;

namespace ZX.BLL.EHR.Time
{
    public class Ehr_EmpwkCardData
    {
        //EmployeeID,CardDate,MinCardTime,MaxCardTime 
        public Guid EmployeeID { get; set; }
        public string CardDate { get; set; }
        public string MinCardTime { get; set; }
        public string MaxCardTime { get; set; }
        

        public Ehr_EmpwkCardData() { }

        public Ehr_EmpwkCardData(Guid xEmployeeID, string xCardDate)
        {
            try
            {
                GetEmpwkCardData(xEmployeeID, xCardDate);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        
        }
        private void GetEmpwkCardData(Guid xEmployeeID, string xCardDate) 
        {
            try
            {
                using (var db = DBHelper.CreateDb(ConnectionStringNames.OpenExpressApp))
                {
                    IResultSet rs = db.Exec("sp_HR_GetEmpwkCardData", new object[] { xEmployeeID, xCardDate });
                    if (rs.Rows > 0)
                    {                
                        EmployeeID = xEmployeeID;
                        CardDate = (rs.Get(0, "CardDate") == null) ? "" : rs.Get(0, "CardDate").ToString();
                        MinCardTime = (rs.Get(0, "MinCardTime") == null) ? "" : rs.Get(0, "MinCardTime").ToString();
                        MaxCardTime = (rs.Get(0, "MaxCardTime") == null) ? "" : rs.Get(0, "MaxCardTime").ToString();
                    }
                    
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
